<template>
  <div>
    <h2>员工添加</h2>
    <table>
      <tbody>
        <tr>
          <td>姓名</td>
          <td><input type="text" v-model="form.name" /></td>
        </tr>
        <tr>
          <td>角色</td>
          <td><input type="text" v-model="form.juese" /></td>
        </tr>
        <tr>
          <td>手机号</td>
          <td><input type="text" v-model="form.phone" /></td>
        </tr>
        <tr>
          <td>备注</td>
          <td><input type="text" v-model="form.beizhu" /></td>
        </tr>
        <tr>
          <td></td>
          <td><button class="btn btn-primary" @click="Add">添加</button></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { ref, reactive, onMounted } from "vue";
import { useRoute } from "vue-router";

const form = reactive({
  id: 0,
  name: "",
  juese: "",
  phone: "",
  beizhu: "",
  zhuangtai: "",
});

const Add=()=>{
    if(form.name==""){
        alert("姓名不能为空");
        return;
    }
    if(form.juese==""){
        alert("角色不能为空");
        return;
    }
    if(form.phone==""){
        alert("手机号不能为空");
        return;
    }
    if(form.beizhu==""){
        alert("备注不能为空");
        return;
    }
    axios.post("https://localhost:7010/api/User/AddUser",form).then(res=>{
        if(res.data>0){
            alert("添加成功");
            return;
        }
        else
        {
            alert("添加失败");
            return;
        }
        
    })

}
</script>

<style scoped></style>
